using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net.Mail;
using System.Text;
using System.Xml.Xsl;
using System.Xml;

using Microsoft.TeamFoundation.VersionControl.Client;

using TfsSpam.Utilities;
using TfsSpam.Differ;
using TfsSpam.Differ.Logging;

namespace TfsSpam.Test
{
    class Program
    {
        static void Main()
        {
            SendCheckinEmails();
        }

        /// <summary>
        /// In lieu of the sorely needed unit tests, this function can be used run
        /// the code that processes a changeset.
        /// </summary>
        [SuppressMessage( "Microsoft.Performance", "CA1811" )]
        static void SendCheckinEmails()
        {
            // !Configure!
            SendCheckinEmail( 43310 );
            SendCheckinEmail( 43459 );
            SendCheckinEmail( 43383 );
            SendCheckinEmail( 43385 );
            SendCheckinEmail( 43486 );
            SendCheckinEmail( 43495 );
            SendCheckinEmail( 43524 );
            SendCheckinEmail( 43740 );
            SendCheckinEmail( 42409 );
            SendCheckinEmail( 42741 );
            SendCheckinEmail( 43843 );
            SendCheckinEmail( 43857 );
            SendCheckinEmail( 43902 );
            SendCheckinEmail( 43912 );
            SendCheckinEmail( 43925 );
            SendCheckinEmail( 43380 );
            SendCheckinEmail( 43747 );
            SendCheckinEmail( 43818 );
            SendCheckinEmail( 43819 );
            SendCheckinEmail( 43961 );
            SendCheckinEmail( 44091 );
            SendCheckinEmail( 44126 );
            SendCheckinEmail( 45200 );
            SendCheckinEmail( 45208 );
            SendCheckinEmail( 45450 );
            SendCheckinEmail( 45682 );
            SendCheckinEmail( 45767 );
        }

        [SuppressMessage( "Microsoft.Performance", "CA1811" )]
        static void SendCheckinEmail( int changesetId )
        {
            try
            {
                CheckinEventProcessor processor = new CheckinEventProcessor( changesetId, ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None ) );

                Console.WriteLine( "Processing changeset id {0}", changesetId );
                processor.ProcessChangeset();
                Console.WriteLine( "\t...done" );
            }
            catch ( CheckinEventProcessorException ex )
            {
                Console.WriteLine( "Exception" );
                Console.WriteLine( "\tType:    {0}", ex.GetType().FullName );
                Console.WriteLine( "\tMessage: {0}", ex.Message );
            }
        }
    }
}
